Skip to content

Unmanaged gradient accumulation: ZeRO stage 3 support - #8217

Merged
sfc-gh-truwase merged 1 commit into
masterfrom
sfc-gh-truwase/gas_mgmt_zero3
Aug 5, 2026
Merged

sfc-gh-truwase merged 1 commit into
masterfrom
sfc-gh-truwase/gas_mgmt_zero3

Conversation

@sfc-gh-truwase

Copy link
Copy Markdown
Collaborator

Summary

  • Extends unmanaged gradient accumulation (managed_gradient_accumulation=false) to ZeRO stage 3 (non-offload). Stacked follow-up to Unmanaged gradient accumulation: ZeRO stage 2 support #8203 (now merged).
  • Stage 3 partitions gradients into __param_id_to_grad_partition on every backward() (as in managed mode); step() only marks the boundary via finalize_gradient_accumulation_boundary().
  • Since stage 3 is now permitted, also reject ZeRO parameter offload (previously unreachable behind the stage-3 guard). ZeRO optimizer-state offload, pipeline parallelism, DeepCompile, and Apex AMP remain unsupported pending follow-ups.

Test plan

Validated on a 2-GPU node:

  • Full -k Unmanaged suite (29 passed), including test_unmanaged_matches_managed[3] and test_unmanaged_varying_backward_count[3]
  • Stage-3 unmanaged feature subset (10 passed)
  • Core ZeRO-3 regression (test_zero_grad_clip, test_zero_leaf_module, test_zero_context, test_zero_tensor_fragment): 158 passed, 62 skipped (expected)

Docs (config-json.md, training.rst) updated; previewable on rtd-staging.

Made with Cursor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 25f5817973

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread deepspeed/runtime/engine.py Resolved
Comment thread deepspeed/runtime/engine.py Resolved
@sfc-gh-truwase
sfc-gh-truwase requested a review from stas00 August 5, 2026 18:12
Allow managed_gradient_accumulation=False for ZeRO stage 3 (non-offload).
Stage 3 partitions gradients into __param_id_to_grad_partition on every
backward (as in managed mode); step() only marks the boundary via
finalize_gradient_accumulation_boundary(). Since stage 3 is now permitted,
also reject ZeRO parameter offload (previously unreachable). ZeRO offload
(optimizer state and parameter) remains rejected pending the follow-up PR;
pipeline parallelism, DeepCompile, and Apex AMP stay unsupported.

Validated on a 2-GPU node (full -k Unmanaged suite, 29 passed) incl.
test_unmanaged_matches_managed[3] and test_unmanaged_varying_backward_count[3].

Signed-off-by: Olatunji Ruwase <tunji.ruwase@snowflake.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@sfc-gh-truwase
sfc-gh-truwase force-pushed the sfc-gh-truwase/gas_mgmt_zero3 branch from 25f5817 to ea671a5 Compare August 5, 2026 18:34
@sfc-gh-truwase
sfc-gh-truwase added this pull request to the merge queue Aug 5, 2026
Merged via the queue into master with commit e75d115 Aug 5, 2026
12 checks passed
@sfc-gh-truwase
sfc-gh-truwase deleted the sfc-gh-truwase/gas_mgmt_zero3 branch August 5, 2026 22:37
banxingmjj pushed a commit to openanolis/DeepSpeed that referenced this pull request Aug 9, 2026
## Summary
* Extends unmanaged gradient accumulation
(`managed_gradient_accumulation=false`) to **ZeRO optimizer-state and
parameter offload** (CPU/NVMe). Follow-up to deepspeedai#8217 (ZeRO stage 3, now
merged).
* Stage 2/3: grads still reduce/partition every `backward()`; `step()`
finalizes deferred offload boundary work (grad norms + FP32/NVMe copy)
via `finalize_gradient_accumulation_boundary()`.
* Stage 1: continues to reduce at `step()` via `allreduce_gradients()`,
which already performs offload boundary finalization when the boundary
flag is true.
* Pipeline parallelism, DeepCompile, Apex AMP, and stage-0/1
`overlap_comm` remain unsupported.

## Test plan
Validated on a 2-GPU node:
* [x] Full `-k Unmanaged` suite (**31 passed**), including:
  * `test_unmanaged_matches_managed_optimizer_offload[1|2|3]`
  * `test_unmanaged_matches_managed_param_offload` (stage 3)
* existing non-offload unmanaged equivalence / varying-GAS / rejection
tests
* [x] Docs updated (`config-json.md`, `training.rst`); previewable on
`rtd-staging`

Made with [Cursor](https://cursor.com)

---------

Signed-off-by: Olatunji Ruwase <tunji.ruwase@snowflake.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Ma, Guokai <guokai.ma@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants